package com.huawei.aiservice.controller;

import com.huawei.aiservice.entity.vo.ReportDetail;
import com.huawei.aiservice.entity.vo.Response;
import com.huawei.aiservice.enums.ControllerConstants;
import com.huawei.aiservice.service.FileService;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * 文件控制器
 */
@RestController
@RequestMapping(path = "/aiService/file", produces = {ControllerConstants.APPLICATION_JSON_PRODUCE},
        consumes = {ControllerConstants.APPLICATION_JSON_CONSUMER})
public class FileController {
        @Resource
        private FileService fileService;

        @RequestMapping(value = "/check", produces = {"application/json"},
                method = RequestMethod.POST)
        public Response<String> check(@RequestPart("files") MultipartFile[] files,
                                      @RequestParam("fullPath") String fullPath,
                                      @RequestParam(value = "fragment", required = false) String fragment,
                                      @RequestHeader Map<String, String> headers) {
                return fileService.check(files, fragment, headers, fullPath);
        }

        @RequestMapping(value = "/detail", produces = {"application/json"}, consumes = {"*/*;charset=UTF-8"},
                method = RequestMethod.POST)
        public Response<ReportDetail> detail(@RequestParam("reportId") int reportId) {
                return fileService.detail(reportId);
        }

}
